import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;

public class Gui extends JFrame {
	ImageIcon img = new ImageIcon(	"C://Users//Daniel//workspace//Project_Test//search2.png");
	ImageIcon logo = new ImageIcon(	"C://Users//Daniel//workspace//Project_Test//eat24.png");

	JButton button;
	JTextField textfield, username;
	JLabel label1, userlabel, passlabel;
	JPasswordField Adminpass;
	Database getInfo;

	public Gui() {

		super("Project");
		setLayout(new BorderLayout());
		JPanel panel = new JPanel();
		JPanel logopanel = new JPanel();
		JPanel loginpanel = new JPanel();

		// Adds logo to logopanel here
		label1 = new JLabel();
		label1.setIcon(logo);
		logopanel.add(label1);

		panel.setBackground(Color.orange);
		loginpanel.setBackground(Color.WHITE);

		// Admin Part
		username = new JTextField(10);
		userlabel = new JLabel("Username");
		passlabel = new JLabel("Password");
		Adminpass = new JPasswordField(10);
		loginpanel.add(userlabel);
		loginpanel.add(username);
		loginpanel.add(passlabel);
		loginpanel.add(Adminpass);

		// TextField search
		textfield = new JTextField("Search...", 50);
		Border roundedBorder = new LineBorder(Color.WHITE, 3, true);
		textfield.setBorder(roundedBorder);
		panel.add(textfield);
		// TextField Ends Here

		button = new JButton("Search", img);
		Border buttonborder = new LineBorder(Color.WHITE, 2, true);
		button.setBorder(buttonborder);
		button.setBackground(Color.orange);
		panel.add(button);

		add(loginpanel, BorderLayout.PAGE_END);
		add(panel, BorderLayout.CENTER);
		add(logopanel, BorderLayout.PAGE_START);

		button.addActionListener(new SearchListener());

	}

	public class SearchListener implements ActionListener {
		public void actionPerformed(ActionEvent event) {
			String search = textfield.getText();
			if (search.isEmpty()) {
				textfield.setText("Search field is empty!");
			}
			try {
				getInfo = new Database(search);

			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}

}
